import {baseUrl} from "./config.js";
export function topList (){
	let listIds = ['3','0','2','1'];
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/toplist/detail`,
			method:'GET',
			data:{},
			success: res => {
				let result = res.data.list;
				result.length = 4;
				for(let i=0;i<listIds.length;i++) {
					result[i].listId = listIds[i];
				}
				resolve(result);
			},
			fial:(err) => {
				reject(err)
			},
			complete:() => {}
		})
	})
}
export function _getList(listId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/playlist/detail?id=${listId}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _songDetail(songId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/song/detail?id=${songId}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _songSimi(songId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/simi/song?id=${songId}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _songComment(songId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/comment/music?id=${songId}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _songLyric(songId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/lyric?id=${songId}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _songUrl(songId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/song/url?id=${songId}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _searchHot(songId) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/search/hot/detail`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _searchWord(word) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/search?keywords=${word}`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}
export function _searchSuggest(word) {
	return new Promise((resolve,reject) => {
		uni.request({
			url:`${baseUrl}/search/suggest?keywords=${word}&type=mobile`,
			method:'GET',
			success: res => {
				resolve(res);
			},
			fial:(err) => {
				reject(err)
			},
		})
	})
}